

<div class="aw-content-wrap">

    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-6">
                    <div id="main"  style="cursor: default; background-color: rgba(0, 0, 0, 0);">
                        
                    </div>
                </div>
                <div class="col-md-6">
                    <div id="main2" _echarts_instance_="1453182469135" style="cursor: default; background-color: rgba(0, 0, 0, 0);"></div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div id="main3" _echarts_instance_="1453182469133" style="cursor: default; background-color: rgba(0, 0, 0, 0);"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="row mod-echat-info">
        <div class="col-md-6">
            <div class="mod">
                <div class="mod-head">
                    <h3>
                        <span class="pull-left">热门话题</span>
                    </h3>
                </div>
                <div class="mod-body tab-content">
                    <table class="table table-striped" id="sorttable">
                        <thead align="center">
                        <tr>
                            <td>话题名称</td>
                            <td>
                                本周/问题数
                                <i class="icon" style="display: none;"></i>
                            </td>
                            <td>
                                本月/问题数
                                <i class="icon hide icon-down"></i>
                            </td>
                            <td>
                                全部/问题数
                                <i class="icon hide" style="display: none;"></i>
                            </td>
                        </tr>
                        </thead>
                        <tbody id="sorttbody"></tbody>
                    </table>
                    <div class="sorttable-mask hide" style="display: block;">
                        <p>当前周期内没有数据！</p>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="mod">
                <div class="mod-head">
                    <h3>
                        <span class="pull-left">系统信息</span>
                    </h3>
                </div>
                <div class="tab-content mod-content">
                    <table class="table table-striped">
                        <tbody>
                        <tr>
                            <td>操作系统</td>
                            <td>Windows NT 6.2</td>
                        </tr>
                        <tr>
                            <td>PHP 版本</td>
                            <td>5.5.12</td>
                        </tr>
                        <tr>
                            <td>MySQL 版本</td>
                            <td>5.6.17</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="mod">
                <div class="mod-head">
                    <h3>
                        <span class="pull-left">用户数据</span>
                    </h3>
                </div>
                <div class="tab-content mod-content">
                    <table class="table table-striped">
                        <tbody>
                        <tr>
                            <td>会员总数</td>
                            <td>2</td>
                        </tr>
                        <tr>
                            <td>Email 激活会员</td>
                            <td>1</td>
                        </tr>
                        <tr>
                            <td>问题总数</td>
                            <td>2</td>
                        </tr>
                        <tr>
                            <td>回答总数</td>
                            <td>0</td>
                        </tr>
                        <tr>
                            <td>等待回答的问题</td>
                            <td>2</td>
                        </tr>
                        <tr>
                            <td>最佳答案数量</td>
                            <td>0</td>
                        </tr>
                        <tr>
                            <td>话题总数</td>
                            <td>1</td>
                        </tr>
                        <tr>
                            <td>附件总数</td>
                            <td>0</td>
                        </tr>
                        <tr>
                            <td>待审核问题</td>
                            <td>0</td>
                        </tr>
                        <tr>
                            <td>待审核回答</td>
                            <td>0</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    // 路径配置
    require.config({
        paths: {
            echarts: 'http://echarts.baidu.com/build/dist'
        }
    });

    // 使用
    require(
        [
            'echarts',
            'echarts/theme/macarons',
            'echarts/chart/bar' // 使用柱状图就加载bar模块，按需加载
        ],
        function (ec,theme) {
            //通过Ajax获取数据
            $.ajax({
                type: "post",
                async: false, //同步执行
                url: "question",
                dataType: "json",
                success:function (result) {
                    if (result) {
                        //将返回的category和series对象赋值给options对象内的category和series
                        //因为xAxis是一个数组 这里需要是xAxis[i]的形式
                        num = [];
                        day = [];
                        for(var row in result){
                            num[row] = result[row].num;
                            day[row] = result[row].day;
                        }
                        max = Math.max.apply(null, num)+1;
                    }
                },
                error: function (errorMsg) {
                    alert("不好意思，大爷，图表请求数据失败啦!");
                }
            });

            // 基于准备好的dom，初始化echarts图表
            var myChart = ec.init(document.getElementById('main'),theme);

            option = {
                tooltip : {
                    trigger: 'axis'
                },
                toolbox: {
                    show : true,
                    feature : {
                        saveAsImage : {show: true}
                    }
                },
                calculable : true,
                legend: {
                    data:['问题量']
                },
                xAxis : [
                    {
                        type : 'category',
                        data : day
                    }
                ],
                yAxis : [
                    {
                        type : 'value',
                        name : '数量',
                        min: 0,
                        max: max,
                        interval: 25,
                        axisLabel : {
                            formatter: '{value} 个'
                        }
                    }
                ],
                series : [

                    {
                        name:'问题量',
                        type:'bar',
                        data:num
                    }
                ]
            };



            // 为echarts对象加载数据
            myChart.setOption(option);
        }
    );

</script>


